var babyObj = function()
{
	this.x,this.y;
	this.angle;
	//this.babyEye = new Image();
	this.babyBody = new Image();
	this.babyTail = new Image();

	this.babyTailTimer = 0;
	this.babyTailCount = 0;

	this.babyEyeTimer = 0;
	this.babyEyeCount = 0;
	this.babyEyeInterval = 1000;

	this.babyBodyTimer = 0;
	this.babyBodyIndex = 0;
}
babyObj.prototype.init = function(){
	this.x = canWidth * 0.5- 50;
	this.y = canHeight* 0.5 + 50;
	this.angle = 0;
	//this.babyEye.src = "./src/babyEye0.png";
	//this.babyBody.src = "./src/baby.png";
	this.babyTail.src = "./src/babyTail0.png";
}
babyObj.prototype.draw = function(){
	//lerp x,y
	this.x = lerpDistance(mom.x,this.x,0.98);
	this.y = lerpDistance(mom.y,this.y,0.98);
	//lerp angle
	var deltaY = mom.y - this.y;
	var deltaX = mom.x - this.x;
	var beta = Math.atan2(deltaY,deltaX) + Math.PI;//-PI,PI
	//lerp angle
	this.angle = lerpAngle(beta,this.angle,0.6);
	//baby tail count
	this.babyTailTimer += deltaTime;
	if(this.babyTailTimer > 50){
		this.babyTailCount = (this.babyTailCount+1) % 8;
		this.babyTailTimer %= 50;
	}	
	//baby eye
	this.babyEyeTimer += deltaTime;
	if(this.babyEyeTimer > this.babyEyeInterval){
		this.babyEyeCount = (this.babyEyeCount+1)%2;
		this.babyEyeTimer %= this.babyEyeInterval;
		if(this.babyEyeCount == 0){//睁开眼睛的时间间隔
			this.babyEyeInterval = Math.random() * 1500 + 2000;//[）
		}else{
			this.babyEyeInterval = 200;
		}
	}
	//baby body
	this.babyBodyTimer += deltaTime;
	if(this.babyBodyTimer > 300){
		this.babyBodyIndex ++;
		this.babyBodyTimer %= 300;
		if(this.babyBodyIndex > 19){
			this.babyBodyIndex = 19;
			//game over
			data.gameOver = true;
		}
	}
	//cxt1
	ctx1.save();
	ctx1.translate(this.x,this.y);
	ctx1.rotate(this.angle);
	this.babyTail = babyTail[this.babyTailCount];
	ctx1.drawImage(this.babyTail,-this.babyTail.width*0.5+23,-this.babyTail.height*0.5);
	this.babyBody = babyBody[this.babyBodyIndex];
	ctx1.drawImage(this.babyBody,-this.babyBody.width*0.5,-this.babyBody.height*0.5);
	var babyEyeImage = babyEye[this.babyEyeCount];
	ctx1.drawImage(babyEyeImage,-babyEyeImage.width*0.5,-babyEyeImage.height*0.5);	
	ctx1.restore();
}
